package com.yjyw.tiexie.common;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;

import com.yjyw.tiexie.application.MyApplication;
import com.yjyw.tiexie.util.LogUtil;

public class OnBack {
    private Context context;

    public OnBack() {
        context = MyApplication.getContext();
    }

    public static OnBack getInstance() {
        return InnerClass.instance;
    }

    public void onBack() {
        LogUtil.e("onBack", "前后台：App进入后台");
        GlobalConstant.isFront = false;
        new Handler(Looper.getMainLooper()).post(new Runnable() {
            @Override
            public void run() {
                doSomeThing();
            }
        });
    }

    private void doSomeThing() {
        long backHomeTime = System.currentTimeMillis();
        LogUtil.e("onBack","本次前台时间：" + (backHomeTime - OnFront.ON_FRONT_TIME) / 1000);

    }

    private static class InnerClass {
        @SuppressLint("StaticFieldLeak")
        private static OnBack instance = new OnBack();
    }
}
